import 'package:stack_trace/stack_trace.dart';

class PageInfoUtil {
  static List<String> blockWidgetType = [];

  static void setIgnoreWidgetType(String type) {
    if (blockWidgetType.contains(type)) {
      return;
    }
    blockWidgetType.add(type);
  }

  static String getLocation() {
    var traceFrames = Trace.current().frames;
    var callFrame = 'unknown';
    if (traceFrames.length >= 5) {
      var name = traceFrames[4].library;
      var startIndex = name.lastIndexOf('/') + 1;
      var endIndex = name.length;
      callFrame =
          '${name.substring(startIndex, endIndex)}(${traceFrames[4].line}:${traceFrames[4].column})';
    }

    return callFrame;
  }
}
